package com.benefm.multipar.pad.ui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.benefm.multipar.pad.AppConfig;
import com.benefm.multipar.pad.dashboard.OnlineDeviceActivity;
import com.benefm.multipar.pad.model.LoginInfo;
import com.benefm.multipar.pad.util.ACache;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new Handler(Looper.getMainLooper()).postDelayed(() -> {
            LoginInfo info = (LoginInfo) ACache.get(this).getAsObject(AppConfig.LOGIN_INFO);
            if (null == info) {
                startActivity(new Intent(this, LoginActivity.class));
            } else {
                startActivity(new Intent(this, OnlineDeviceActivity.class));
            }
            SplashActivity.this.finish();
        }, 200);
    }
}
